package com.lanou.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.entity.Question;
import com.lanou.mapper.QuestionMapper;
import com.lanou.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName QuestionServiceImpl
 * @Description TODO
 * @Author chenzhaobao
 * @Date 2025年08月14日 11:21
 * @Version 1.0
 */
@Service
public class QuestionServiceImpl implements QuestionService {
    @Autowired
    private QuestionMapper questionMapper;
    @Override
    public int insert(Question question) {
        return questionMapper.insert(question);
    }

    @Override
    public int deleteById(Integer id) {
        return questionMapper.deleteById(id);
    }

    @Override
    public int updateById(Question question) {
        return questionMapper.updateById(question);
    }

    @Override
    public Question selectById(Integer id) {
        return questionMapper.selectById(id);
    }

    @Override
    public List<Question> selectAll() {
        return questionMapper.selectAll();
    }

    @Override
    public List<Question> selectByUserId(Integer userId) {
        return questionMapper.selectByUserId(userId);
    }

    @Override
    //根据id过滤咨询师分页查询
    public PageInfo<Question> selectjl(Integer consultantId, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        // 直接传递 consultantId
        List<Question> selectjl = questionMapper.selectjl(consultantId);
        return new PageInfo<>(selectjl);
    }
}
